package com.github.ecbp.store.service.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.github.ecbp.common.data.entity.BaseEntity;
import com.github.ecbp.common.data.service.impl.BaseServiceImpl;
import com.github.ecbp.store.service.entity.FreightTemplate;
import com.github.ecbp.store.service.mapper.FreightTemplateMapper;
import com.github.ecbp.store.service.service.FreightTemplateService;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

/**
 * @Author Created by Alex·He on 2020/4/30 22:17
 * @Version V1.0
 * @Description: 运费模版表(FreightTemplate)表服务实现类
 */
@Service
public class FreightTemplateServiceImpl extends BaseServiceImpl<FreightTemplateMapper, FreightTemplate>
        implements FreightTemplateService {

    @Override
    protected void assemble(FreightTemplate entity, LambdaQueryWrapper<FreightTemplate> wrapper) {
        super.assemble(entity, wrapper);
        if (!StringUtils.isEmpty(entity.getName())) {
            wrapper.likeRight(FreightTemplate::getName, entity.getName());
        }
        wrapper.orderByDesc(BaseEntity::getCreateTime);
    }
}
